package com.example.demo;

import java.util.Observable;
import java.util.Observer;

/**
 * 老师类--观察者
 * Created by Easettle
 * Date:2021-02-18 15:43
 * Email:easettle@qq.com
 */
public class Teacher implements Observer {
    private String name;

    public Teacher(String name) {
        this.name = name;
    }

    public void update(Observable observable, Object o) {
        Easettle easettle = (Easettle) observable;
        Question question = (Question) o;
        System.out.println("----------------");
        System.out.println(name + "老师,您好！\n" + "您收到了一个来自" + easettle.getName() + "的提问，希望您解答,问题内容如下:\n" +
                question.getContent() + "提问者是:" + question.getUserName());
    }
}
